<?php

defined('JOC') or die;
/*-------------------------------------------------------|
 * JOC Class.                                            +
 * ------------------------------------------------------|
 * Description :                                         +
 * This helper class is used to load and intance class.  +
 * ------------------------------------------------------|
 */
class joc extends Helper {
  
  static function instance($classname, $params = Array())
  {
    $class = strtolower($classname) ;
  
    //try to include DBTable Classes
    if (file_exists(ROOT.'/core/model/'.$class.'.class.php'))
    {
      require_once(ROOT.'/core/model/'.$class.'.class.php') ;
    }
    //try to include Modules Classes
    else if (file_exists(ROOT.'/core/module/'.$class.'.class.php'))
    {
      require_once(ROOT.'/core/module/'.$class.'.class.php') ;
    }
    //try to include Common Functions Classes
    else if (file_exists(ROOT.'/core/function/'.$class.'.class.php'))
    {
      require_once(ROOT.'/core/function/'.$class.'.class.php') ;
    }
    //try to include Render Classes
    else if (file_exists(ROOT.'/core/render/'.$class.'.class.php'))
    {
      require_once(ROOT.'/core/render/'.$class.'.class.php') ;
    }
    return new $classname($params) ;
  }
  static function model($classname, $params = Array())
  {
    $classname = $classname.'_model' ;
    $class = strtolower($classname) ;
    
    if (file_exists(ROOT.'/core/model/'.$class.'.class.php'))
    {
      require_once(ROOT.'/core/model/'.$class.'.class.php') ;
    }
    if(class_exists($classname))
    {
      return new $classname($params) ;
    }
  }
  static function module($classname, $params = Array())
  {
    $class = strtolower($classname) ;
    
    if (file_exists(ROOT.'/core/module/'.$class.'.class.php'))
    {
      require_once(ROOT.'/core/module/'.$class.'.class.php') ;
    }
    if(class_exists($classname))
    {
      return new $classname($params) ;
    }
  }
  static function helper($classname, $params = Array())
  {
    $class = strtolower($classname) ;
    
    if (file_exists(ROOT.'/core/helper/'.$class.'.class.php'))
    {
      require_once(ROOT.'/core/helper/'.$class.'.class.php') ;
    }
    if(class_exists($classname))
    {
      return new $classname($params) ;
    }
  }
}
/*
 * ---------------------------------------------------------+
 * End of file joc.class.php                                |
 * ---------------------------------------------------------+
 * located at core/helper/joc.class.php                     |
 * ---------------------------------------------------------+
*/